<?php
use Illuminate\Support\Facades\View;
class ScoreHistoryController extends CenterController {
	
	public function listScores()
	{
        $page = Input::get('page', 1);
        $rows_per_page = Input::get('rows_per_page', PaginationHelper::ROWS_PER_PAGE);
		$offset = ($page-1) * $rows_per_page;
        $scores = UserScoresHistory::getScoreHistorys($rows_per_page, $offset);
        $scoresArr = $scores->toArray();
		$score_rules = Config::get('site.score_rules');
		// 不显示下面的fields
		$blacklists = array('id', 'user_id', 'unique_event', 'ip', 'user_agent', 'request_url', 'operator_id', 'updated_at');
		$blacklists = array_flip($blacklists);
		$totalScore = 0;
		foreach($scoresArr as $key => $score) {
			$score['title'] = $score_rules[$score['action']];
			$scoresArr[$key] = array_diff_key($score, $blacklists);
			$totalScore += $score['score'];
		}

		if (Route::is('center.lawyer.score')) {
			$this->layout = View::make('layouts.lawyercenter');
		}

        return $this->makeView('center.score.list', $scoresArr, 200);
	}
}